package com.beyond.framework.privilege.domain;

import com.beyond.framework.privilege.annotations.Privilege;

import javax.persistence.Entity;

/**
 * Created by IntelliJ IDEA.
 * User: lewisw
 * Date: Sep 19, 2010
 * Time: 10:19:43 AM
 */
@Entity
public class PrivilegeEntity {

    private Integer id;

    private String value;

    private boolean isEntrance;

    private Integer order;

    public PrivilegeEntity() {
    }

    private PrivilegeEntity(String value, boolean entrance, Integer order) {
        this.value = value;
        isEntrance = entrance;
        this.order = order;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public boolean isEntrance() {
        return isEntrance;
    }

    public void setEntrance(boolean entrance) {
        isEntrance = entrance;
    }

    public Integer getOrder() {
        return order;
    }

    public void setOrder(Integer order) {
        this.order = order;
    }

    public static PrivilegeEntity wrap(Privilege privilege) {
        return new PrivilegeEntity(
                privilege.value(), privilege.isEntrance(), privilege.order());
    }
}
